@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            <form id="search_form" method="GET">
                <label>
                    消息类型：<br>
                    <select class="form-control search_form_control" name="is_system">
                  
                        <option value="1" @if($_search['is_system']==1)selected="" @endif>系统消息</option>
                        <option value="0" @if($_search['is_system']==0)selected="" @endif>私有信息</option>
                    </select>
                </label>
                <label>
                    内容：<br>
                    <input name="key" type="text" class="form-control search_form_control" value="{{ $_search['key'] }}">
                </label>
                
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div id="order_tag"></div>

        <div class="table-responsive">
            <table class="table">
                <caption>消息列表</caption>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>标题</th>
                        <th>Uid</th>
                        <th>内容</th>
                        <th>添加时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>{{ $item->id }}</td>
                            <td>{{ $item->uid }}</td>
                            <td>{{ $item->title }}</td>
                            <td>{{ $item->content }}</td>
                            <td>{{ date('Y/m/d H:i:s',$item->add_time) }}</td>
                      
                            <td>
                                <!--
                                <a href="/Theme/edit/{{ $item->id }}">编辑</a>
                                <a href="javascript:;" onclick="ajax_delete_theme(<?=$item->id?>)">删除</a>
                                -->
                            </td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="7">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/theme/ajax_delete_theme/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
</script>
@endsection